<%@ page import="bcared.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>

<%
	ResultSet rs = null;
	CallableStatement csmt = null;
	PreparedStatement ps = null;
	OraDB myDB = new OraDB();
   	
   	myDB.createConnection();
   	String myQuery = "SELECT priorityID FROM serviceordertype where serviceordertypeid = ?";
   	ps = myDB.conn.prepareStatement(myQuery);
   	ps.setInt(1, Integer.parseInt(request.getParameter("serviceOrderTypeID")));
	rs = ps.executeQuery();
	
	int priorityID = 0;
	int soStatusID = 0;

	while (rs.next()) {
		priorityID = rs.getInt("priorityID");
	}



		int serviceOrderTypeID = Integer.parseInt(request.getParameter("serviceOrderTypeID"));
		int equipmentID = Integer.parseInt(request.getParameter("equipmentID"));
		int customerID = Integer.parseInt(request.getParameter("customerID"));
		String contactName = request.getParameter("contactName");
		String contactPhone = request.getParameter("contactPhone");
		String contactEmail = request.getParameter("contactEmail");
		String problemDesc = request.getParameter("problemDesc");
		int lifeInDanger = 0;

if (request.getParameter("lifeInDanger") != null) {
	lifeInDanger = 1;
}

;

if (priorityID == 4) {
	soStatusID = 6; //1 for remote
} else if (priorityID == 3) {
	soStatusID = 6; //7 for remote
} else {
	soStatusID = 6;
}

ServiceOrder so = new ServiceOrder();
so.insert(priorityID, soStatusID, serviceOrderTypeID, equipmentID, customerID, contactName, contactPhone, contactEmail, problemDesc, lifeInDanger);

response.sendRedirect("customerhome.jsp");
		
%>